/**
 * 
 */
package com.newtribe.security.cert;

import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;

import com.newtribe.security.remote.WorkerInstanceRemote;

/**
 * @author newtribe
 *
 */
public class ManagedStarer {

	/**
	 * @param args
	 */
	public  void startServer() throws Exception{
		
	    if(System.getSecurityManager()==null)

            System.setSecurityManager(new RMISecurityManager());
	    
		// TODO Auto-generated method stub
		System.out.println("================== starter ......");
	    DomainFactory factory =DomainFactory.getFactory() ;
	     
	     WorkerInstanceRemote instance =factory.getWorkerInstance("default") ;
	     System.out.println(instance);
	     
	     int listenPort =instance.getCaConfig().getListenPort();
	     //listen on port use a rmi Protocol .
	     LocateRegistry.createRegistry(listenPort);
	     Naming.bind("ca", instance);

	     System.out.println("rmi registry ca service  ok !");

	}

}
